package fr.umlv.m2.jee.portailEtudiant.persistence.DAO;

import fr.umlv.m2.jee.portailEtudiant.framework.dao.hibernate.AbstractHibernateDAO;
import fr.umlv.m2.jee.portailEtudiant.persistence.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 20/02/11
 * Time: 18:00
 * To change this template use File | Settings | File Templates.
 */
@Repository("hibernateCourseDAO")
public class HibernateCourseDAO extends AbstractHibernateDAO<Long, Course> implements ICourseDAO {

    public Course findByCourseId(long id) {
        return super.findEntityByQuery("FROM Course b WHERE b.idCourse ='"+id+"'");
    }

    @Override
    public List<Td> findTdsByCourseId(String id) {
        return super.findEntityByQuery("FROM Course WHERE COURSE_NAME ='"+id+"'").getTds();

    }

    @Override
    public List<Tp> findTpsByCourseId(String id) {
         return super.findEntityByQuery("FROM Course  WHERE COURSE_NAME ='"+id+"'").getTps();
    }

    @Override
    public List<Tutorial> findTutorialsByCourseId(String id) {
        return super.findEntityByQuery("FROM Course  WHERE COURSE_NAME ='"+id+"'").getTutorials();
    }

    @Override
    public List<CourseDocument> findDocumentByCourseId(String id) {
        return super.findEntityByQuery("FROM Course  WHERE COURSE_NAME ='"+id+"'").getDocumentList();
    }

}
